<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <input type="text" placeholder="搜索">
    <button>搜索</button>
</body>
<script src="js/jquery.js"></script>
<script>
    $('input').on('input', function () {
        console.log($(this).val());

        var data = {
            val: $(this).val()
        };
        console.log(data.val.length);

        if (data.val.lenght != 0) {
            $.post('/comment/search', data, function (resData) {
                console.log(resData.message);
            })
        }

    })
</script>

</html>